package com.huawei.appmarket.service.store.awk.card;

import android.content.Context;
import android.graphics.Bitmap;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.TextView;
import com.huawei.appgallery.foundation.card.base.card.BaseDistCard;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appmarket.framework.widget.CustomActionBar;
import com.huawei.appmarket.service.store.awk.bean.ImmersiveHeadVideoCardBean;
import com.huawei.appmarket.support.video.VideoPlayer;
import o.cgz;
import o.chy;
import o.Logger;
import o.epv;
import o.eqx;
import o.eqz;
import o.erq;
import o.evp.b;
import o.evt;
import o.ewm.j;

public class ImmersiveHeadVideoCard extends BaseDistCard implements eqz {
    private VideoPlayer ʼ;
    private String ʽ;
    private TextView ˋ;
    private TextView ॱॱ;

    public ImmersiveHeadVideoCard(Context context) {
        super(context);
    }

    public void ˏ(CardBean cardBean) {
        super.ˏ(cardBean);
        if (cardBean != null && (cardBean instanceof ImmersiveHeadVideoCardBean)) {
            ImmersiveHeadVideoCardBean immersiveHeadVideoCardBean = (ImmersiveHeadVideoCardBean) cardBean;
            int i = j.ʿˈ;
            int i2 = j.ʿʿ;
            String str = (String) this.ˋ.getTag(i);
            String str2 = (String) this.ˋ.getTag(i2);
            String ʼˋ = immersiveHeadVideoCardBean.ʼˋ();
            String ʻˋ = immersiveHeadVideoCardBean.ʻˋ();
            ˊ(immersiveHeadVideoCardBean.ʽˋ(), immersiveHeadVideoCardBean.ʻˊ());
            if (!TextUtils.isEmpty(str) && str.equals(ʻˋ)) {
                return;
            }
            if (TextUtils.isEmpty(str2) || !str2.equals(ʼˋ)) {
                this.ˋ.setTag(i, ʻˋ);
                this.ˋ.setTag(i2, ʼˋ);
                this.ʽ = immersiveHeadVideoCardBean.ʾॱ();
                ˊ(immersiveHeadVideoCardBean.ʻᐝ(), this.ˋ);
                ˊ(immersiveHeadVideoCardBean.ʼˊ(), this.ॱॱ);
                this.ʼ.setVideoBaseInfo(new b().ˎ(immersiveHeadVideoCardBean.ʼᐝ()).ˊ(immersiveHeadVideoCardBean.ʼˋ()).ˋ(immersiveHeadVideoCardBean.ʻˋ()).ˏ(immersiveHeadVideoCardBean.ͺˏ()).ॱ(immersiveHeadVideoCardBean.u_()).ʼ(immersiveHeadVideoCardBean.ʽˊ()).ᐝ(immersiveHeadVideoCardBean.ʽᐝ()).ʻ(evt.ˏ(immersiveHeadVideoCardBean.sp_)).ॱॱ(immersiveHeadVideoCardBean.ॱـ()).ॱ());
                eqx.ˎ(this.ʼ.ॱॱ(), immersiveHeadVideoCardBean.ʼˋ(), "image_default_icon", this, true);
            }
        }
    }

    public cgz ˏ(View view) {
        this.ˋ = (TextView) view.findViewById(j.ˈʿ);
        this.ॱॱ = (TextView) view.findViewById(j.ʿʾ);
        this.ʼ = (VideoPlayer) view.findViewById(j.ˊʴ);
        ʽ(view);
        return this;
    }

    private void ˊ(String str, int i) {
        int indexOf;
        float f = 0.75f;
        if (i == 8) {
            f = 0.5625f;
        }
        if (!TextUtils.isEmpty(str) && str.contains("x")) {
            indexOf = str.indexOf("x");
            if (indexOf > 0 && str.length() > indexOf + 1) {
                try {
                    int parseInt = Integer.parseInt(str.substring(0, indexOf).trim());
                    indexOf = Integer.parseInt(str.substring(indexOf + 1, str.length()).trim());
                    if (parseInt > 0) {
                        f = ((float) indexOf) / ((float) parseInt);
                    }
                } catch (NumberFormatException e) {
                    Logger.e("ImmersiveHeadVideoCard", e.toString());
                }
            }
        }
        indexOf = epv.ˎ(this.ʼ.getContext());
        LayoutParams layoutParams = this.ʼ.getLayoutParams();
        layoutParams.height = (int) (f * ((float) indexOf));
        layoutParams.width = indexOf;
        this.ʼ.setLayoutParams(layoutParams);
    }

    private void ˊ(String str, TextView textView) {
        if (textView == null) {
            return;
        }
        if (TextUtils.isEmpty(str)) {
            textView.setVisibility(4);
            return;
        }
        textView.setVisibility(0);
        textView.setText(str);
    }

    public void ॱ(chy o_chy) {
    }

    public void ॱ(Bitmap bitmap) {
        if (bitmap != null) {
            try {
                CustomActionBar.ˎ(this.ʼ.getContext(), erq.ॱ(this.ʽ, bitmap), this.ʼ.ॱॱ().getHeight());
            } catch (IllegalStateException e) {
                Logger.e("ImmersiveHeadVideoCard", e.toString());
            }
        }
    }
}
